<?php
//日志类
class Log
{
	//操作日志写入
	public static function op($manager_id,$action,$content)
	{
		$logs = array('manager_id'=>$manager_id,'action'=>$action,'content'=>$content,'ip'=>Chips::getIP(),'url'=>Url::requestUri(),'time'=>date('Y-m-d H:i:s'));
		$model = new Model('log_operation');
		$model->data($logs)->insert();
	}
	//余额日志变化写入
	public static function balance($amount,$user_id,$note='',$type=0,$admin_id=0)
	{
		//事件类型: 0:订单支付 1:用户充值 2:管理员充值 3:提现
		$model = new Model('customer');
		$customer = $model->fields("balance")->where("user_id=".$user_id)->find();
		if($customer){
			$log = array('amount'=>$amount,'user_id'=>$user_id,'time'=>date('Y-m-d H:i:s'),'amount_log'=>$customer['balance'],'admin_id'=>$admin_id,'type'=>$type,'note'=>$note);
			$model->table("balance_log")->data($log)->insert();
		}
	}

	/** 激活 复投记录日志
	 * @param $id 激活 复投人id
	 * @param $be_user_id 被激活(复投)会员
	 * @param $post  1 激活  2 复投
	 * @param $method 方法
	 * @param $zje   金额
	 * @param $xjf  现金分
	 * @param $zcf  注册分
	 * @param $time 时间
	 */
	public static function active_ft_log ($id,$be_user_id,$post, $method, $zje, $xjf, $zcf, $time)
	{
		$model = new Model('active_ft_list');
		$logs = array(
			'user_id'=>$id,
			'douser_id'=>$be_user_id,
			'post'   =>$post,
			'method' =>$method,
			'zje'    =>$zje,
			'xjf'     =>$xjf,
			'zcf'     =>$zcf,
			'time'    =>$time
		);
		$insert_log = $model->data($logs)->insert();
		if ($insert_log) {
			return true;
		} else {
			return false;
		}
	}
}
?>